Splunk Enterprise Security

How to extract email addresses from URLs using regex?

dsmeerkat
Explorer

I have URL's that contain email addresses that I would like to extract via rex into an email field:

SAMPLE RAW:

macplatform.wondershare.com/interface.php?m=co&client_sign={CD1AABB2-586E-55A5-A891-877563550973}&product_id=735&version=10.3.2&email=Christopher.Nobody@somedomain.com&lang=en_us&type=0&cc=92445606E83D64D283AD3A5EF2A9869E&interface_version=1.1

link.defensenews.com/manage/5ba/preferences-center?email=moe.nobody@domain.org

www2.criver.com/form/checkEmailAjax/account_id/60962/form_field_id/129003/tracker_id/278458707/field_id/60962_129003pi_60962_129003?param=Edward.Nobody2@some.com

login.yahoo.com/account/comm-channel/refresh?display=login&.intl=us&intl=us&.lang=en-US&src=finance&.src=finance&login=kimberly.nobody@somewhere.gov&tn=arinfo_review&context=spreg_cc&.

www.borisfx.com/BCCAVXActivation.php?UPID=MCHITNB-ADRELHQ-OSJZBFU-VYIQAAM&email=ronald.nobody@blahbl...

www.idevmail.net/unsubscribe.aspx?d=94&m=1319&e=jill.nobody2@domain.net

0 Karma

anthonymelita
Contributor

You may want to add other characters like - and _ to the regex. This is primitive and just catching the word and . characters on either side of the @ and assumes your url is delimited with other special chars like = from your examples

| makeresults
| eval foo="macplatform.wondershare.com/interface.php?m=co&client_sign={CD1AABB2-586E-55A5-A891-877563550973}∏uct_id=735&version=10.3.2&email=Christopher.Nobody@somedomain.com⟨=en_us&type=0&cc=92445606E83D64D283AD3A5EF2A9869E∫erface_version=1.1 
link.defensenews.com/manage/5ba/preferences-center?email=moe.nobody@domain.org 
www2.criver.com/form/checkEmailAjax/account_id/60962/form_field_id/129003/tracker_id/278458707/field_id/60962_129003pi_60962_129003?param=Edward.Nobody2@some.com 
login.yahoo.com/account/comm-channel/refresh?display=login&.intl=us∫l=us&.lang=en-US&src=finance&.src=finance&login=kimberly.nobody@somewhere.gov&tn=arinfo_review&context=spreg_cc&. 
www.borisfx.com/BCCAVXActivation.php?UPID=MCHITNB-ADRELHQ-OSJZBFU-VYIQAAM&email=ronald.nobody@blahbl... www.idevmail.net/unsubscribe.aspx?d=94&m=1319&e=jill.nobody2@domain.net";
| makemv foo delim=" "
| mvexpand foo
| rex field=foo "(?<email>[\w\.]+@[\w\.]+)"
| table foo email
0 Karma

smoir_splunk
Splunk Employee
Splunk Employee

Are you asking for the community to write the regex for you? I'm not sure exactly what your question is. What have you tried so far?

0 Karma

dsmeerkat
Explorer

Yes I am new to splunk and I'm not sure how to write this regex...I tried extracting a new field with the tool, but it didn't always work.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...